<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" >
<head>
    <th:block th:include="include :: header('新增入住退房登记')" />
    <th:block th:include="include :: datetimepicker-css" />
</head>
<body class="white-bg">
    <div class="col-sm-12 search-collapse">
        <form id="formId">
            <div class="select-list">
                <ul>
                    <li>
                        <label>姓名：</label>
                        <input type="text" name="name" />
                    </li>
                    <li>
                        <label>手机号码：</label>
                        <input type="text" name="phone" />
                    </li>
                    <li>
                        <label>身份证号码：</label>
                        <input type="text" name="idcard" />
                    </li>
                    <input type="text" name="pageSize" value="1" hidden>
                    <input type="text" name="pageNum" value="1" hidden>
                    <input type="text" name="isAsc" value="1" hidden>
                    <li>
                        <a class="btn btn-primary btn-rounded btn-sm" onclick="getUser()"><i
                                class="fa fa-search"></i>&nbsp;搜索</a>
                        <a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i
                                class="fa fa-refresh"></i>&nbsp;重置</a>
                    </li>
                </ul>
            </div>
        </form>
    </div>
    <script>
        function getUser() {
            $.ajax({
                type: "POST",
                dataType: 'json',
                url: '/user/info/list',
                data: $('#formId').serialize(),
                success: function (data) {
                    if (data['rows'].length <= 0) {
                        alert("用户不存在");
                    } else {
                        $('#phoneNum').val(data['rows'][0]['userId']);
                    }

                },
                error: function (data) {
                    alert("error:" + data.responseText);
                }
            });
        }
    </script>
    <div class="wrapper wrapper-content animated fadeInRight ibox-content">
        <form class="form-horizontal m" id="form-in-add">
            <div class="form-group">    
                <label class="col-sm-3 control-label is-required">订单号：</label>
                <div class="col-sm-8">
                    <input name="orderId" id="orderId" class="form-control" type="text" required readonly>
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label is-required">房间号：</label>
                <div class="col-sm-8">
                    <input name="roomNumber" id="roomNumber" class="form-control" type="text" required readonly>
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label is-required">用户id：</label>
                <div class="col-sm-8">
                    <input name="userId" id="phoneNum" class="form-control" type="text" required readonly>
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">入住时间：</label>
                <div class="col-sm-8">
                    <div class="input-group date">
                        <input name="checkInTime" class="form-control" placeholder="yyyy-MM-dd" type="text">
                        <span class="input-group-addon"><i class="fa fa-calendar"></i></span>
                    </div>
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label is-required">退房时间：</label>
                <div class="col-sm-8">
                    <div class="input-group date">
                        <input name="checkoutOutTime" class="form-control" placeholder="yyyy-MM-dd" type="text" required>
                        <span class="input-group-addon"><i class="fa fa-calendar"></i></span>
                    </div>
                </div>
            </div>
        </form>
    </div>
    <th:block th:include="include :: footer" />
    <th:block th:include="include :: datetimepicker-js" />
    <script th:inline="javascript">
        var prefix = ctx + "order/in"
        $("#form-in-add").validate({
            focusCleanup: true
        });

        function submitHandler() {
            if ($.validate.form()) {
                $.operate.save(prefix + "/add", $('#form-in-add').serialize());
            }
        }
        ( function(){
                var roomId=localStorage.getItem("depositRoomId");
                $("#roomNumber").val(roomId);
                var orderId=localStorage.getItem("depositOrderId");
                $("#orderId").val(orderId);
            }
        )();
        $("input[name='checkInTime']").datetimepicker({
            format: "yyyy-mm-dd",
            minView: "month",
            autoclose: true
        });

        $("input[name='checkoutOutTime']").datetimepicker({
            format: "yyyy-mm-dd",
            minView: "month",
            autoclose: true
        });
    </script>
</body>
</html>